//
//  MDNavigationController.swift
//  麦兜直播
//
//  Created by Apple on 16/10/24.
//  Copyright © 2016年 yeqingyu. All rights reserved.
//

import UIKit

class MDNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //获取系统的pop手势
        
        guard let popReguest = interactivePopGestureRecognizer else{return}
        //获取对应的手势作用的view
        guard let popView = popReguest.view else{return}
        
        //获取target事件
//        var count:UInt32 = 0
//        let list = class_copyIvarList(UIGestureRecognizer.self, &count)!
//        print("list:\(list)")
//        
//        for i in 0..<count {
//            let ivar = list[Int(i)]
//            let name = ivar_getName(ivar)
//            print(String(cString: name!))
//        }
//        
        let tagrets = popReguest.value(forKey: "_targets") as! [NSObject]
        guard let tagretObj = tagrets.first else{return}
        //取出target
        guard let target = tagretObj.value(forKey: "target") else { return }
        
        let action = Selector(("handleNavigationTransition:"))

        let customPop = UIPanGestureRecognizer(target: target, action: action)
       
        popView.addGestureRecognizer(customPop)
    }

    
        override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        viewController.hidesBottomBarWhenPushed = true
        super.pushViewController(viewController, animated: animated)
    }
}
